import os
from locust import TaskSet, task, HttpUser


class msiTask(TaskSet):
    @task
    def live1(self):
        # 获取其他非必要的全局配置 !!!!有
        url = "/appapi/api/config-other?api_version=3.20.1&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&client=android&cms_app_id=19&app_id=2&app_version=4.0.24"
        res = self.client.get(url=url)

    @task
    def live2(self):
        # 获取客户端启动配置！！！！
        url = "/appapi/api/config-other?api_version=3.20.1&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&client=android&cms_app_id=19&app_id=2&app_version=4.0.24"
        res = self.client.get(url=url)

    @task
    def live3(self):
        # 获取导航列表内容！！！！
        url = "/appapi/api/content/list/37?page=2&perPage=20&client=android&api_version=3.20.1&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&cms_app_id=19&app_id=2&app_version=4.0.24"
        res = self.client.get(url=url)

    @task
    def live33(self):
        # 获取评论列表！！！！有
        url = "//cms/api/comment/getMicroCommentList?pageNumber=1&relald=11495661&pageSize=20&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&api_version=3.20.1&app_version=4.0.33&client=android&cms_appid=19&app_id=2&sign=bc352559282c42e20b21f6ef5d263506&no_cache=yes"
        res = self.client.get(url=url)

    @task
    def live34(self):
        # 获取点赞量！！！！有
        url = "/cms/api/praise/getPraiseCount?relationId=11495661&type=1&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&api_version=3.20.1&app_version=4.0.33&client=android&cms_app_id=19&app_id=2&sign=462796f090a333860e7129054268b286&no_cache=yes"
        res = self.client.get(url=url)
    @task
    def live4(self):
        # 获取指定导航的二级导航！！！！有
        url = "/appapi/api/navigate/children?navigate_id=21&have_own=0&api_version=3.20.1&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&client=android&cms_app_id=0&app_id=2&app_version=4.0.24"
        res = self.client.get(url=url)
    @task
    def live44(self):
        # 获取机位列表!!!!有
        url = "/cms/api/micro/live/seat/getList?articleId=11495661&pageSize=500&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&api_version=3.20.1&app_version=4.0.33&client=android&cms_app_id=19&app_id=2&sign=93c47b0a230c4a12fdfa69d0a5f01e34&no_cache=yes"
        res = self.client.get(url=url)

    @task
    def live55(self):
        # 获取直播信息！！！！有
        url = "/cms/api/micro/live/seat/live?articleId=11495661&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&api_version=3.20.1&app_version=4.0.33&client=android&cms_app_id=19&app_id=2&sign=93c47b0a230c4a12fdfa69d0a5f01e34&no_cache=yes"
        res = self.client.get(url=url)

    @task
    def live5(self):
        # 启动APP事件统计
        url = "/appapi/api/config-other?api_version=3.20.1&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&client=android&cms_app_id=19&app_id=2&app_version=4.0.25"
        res = self.client.get(url=url)

    @task
    def live6(self):
        # 我的首页列表接口
        url = "/appapi/api/spider/attention-article-list?access_token=0be00f17-de25-4156-8017-6f83689cf1e1&api_version=3.22.3&app_id=2&app_version=4.0.26&client=ios&page=1&perPage=20&sign=9c59e1d5e0b75a015a76bfa27d22ece4&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&user_id=3635310"
        res = self.client.get(url=url)

    @task
    def live7(self):
        # 推荐冀时号列表
        url = "/appapi/api/spider/get-default-list?access_token=0be00f17-de25-4156-8017-6f83689cf1e1&api_version=3.22.3&app_id=2&app_version=4.0.26&client=ios&page=1&perPage=4&sign=704bc6e08b7c205ece593458a21514e0&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&type=1"
        res = self.client.get(url=url)

    @task
    def live8(self):
        # 推荐律师列表
        url = "/appapi/api/spider/get-default-list?access_token=0be00f17-de25-4156-8017-6f83689cf1e1&api_version=3.22.3&app_id=2&app_version=4.0.26&client=ios&page=1&perPage=4&sign=88668c0f74ddfdc9d115ff1ac037e34f&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&type=2"
        res = self.client.get(url=url)

    @task
    def live9(self):
        # 推荐专题列表
        url = "/appapi/api/content/list/69?api_version=3.22.3&app_id=2&app_version=4.0.26&client=ios&page=1&perPage=4&sign=2aab78f9d195ff43748e3bb5fc92d404&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9"
        res = self.client.get(url=url)

    # @task
    # def live10(self):
    #     # 推荐专题列表
    #     url = "/appapi/api/spider/my-article-list"
    #     data = {
    #         "api_version": "3.22.3",
    #         "app_id	": "2",
    #         "app_version	": "4.0.26",
    #         "client	": "ios",
    #         "orderDirection	": "desc",
    #         "orderField	": "liveStartTime",
    #         "pageNumber	": "1",
    #         "pageSize	": "4",
    #         "publicFlag	": "Y",
    #         "sign	": "3ea70cd9159cf8420238e10ed3959a21",
    #         "status	": "30",
    #         "tenantid	": "0d91d6cfb98f5b206ac1e752757fc5a9",
    #         "type	": "15",
    #         "user_id	": "3635310",
    #     }
    #     res = self.client.post(url=url,data=data)

    @task
    def live11(self):
        # 推荐专题列表
        url = "/appapi/api/livepopup?app_id=2&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9"
        res = self.client.get(url=url)

    @task
    def live12(self):
        # 我的订阅冀时号列表
        url = "/appapi/api/spider/attention-number?access_token=0be00f17-de25-4156-8017-6f83689cf1e1&api_version=3.22.3&app_id=2&app_version=4.0.26&client=ios&page=1&perPage=4&sign=7c2d7db28f5bb44f9826472e48a7e985&spiderType=spider&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&user_id=3635310"
        res = self.client.get(url=url)

    @task
    def live13(self):
        # 我的订阅律师列表
        url = "/appapi/api/spider/attention-number?access_token=0be00f17-de25-4156-8017-6f83689cf1e1&api_version=3.22.3&app_id=2&app_version=4.0.26&client=ios&page=1&perPage=4&sign=30957fe522fa990f85bc575b73b037b5&spiderType=lawyer&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&user_id=3635310"
        res = self.client.get(url=url)

    @task
    def live14(self):
        # 我的订阅直播列表
        url = "/appapi/api/collection/3635310?api_version=3.22.3&app_id=2&app_version=4.0.26&client=ios&page=1&perPage=10&show_source=live&sign=2aee36ed3114912285ca42c1081eca9f&source=1&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&title=&type=15"
        res = self.client.get(url=url)

    @task
    def live15(self):
        # 我的订阅专题列表
        url = "/appapi/api/collection/3635310?api_version=3.22.3&app_id=2&app_version=4.0.26&client=ios&page=1&perPage=4&sign=e63ba656f40cf30aa149345dc3ba3454&source=1&tenantid=0d91d6cfb98f5b206ac1e752757fc5a9&title=&type=8"
        res = self.client.get(url=url)

    @task
    def live16(self):
        # 活动
        url = "/msi/api/activity-enroll-varnish?activity_id=60f58fb0-48fe-4c26-b7f7-05972004c054&group_name=%E8%9E%8D%E5%AA%92%E4%BD%93%E6%96%B0%E9%97%BB%E4%B8%AD%E5%BF%83&sort_type=sort&sort_order=asc"
        res = self.client.get(url=url)

class WebsiteUser(HttpUser):
    # 声明执行的任务集是哪个类
    tasks = [msiTask]
    host = "https://api.cmc.hebtv.com"
    # 最小等待时间和最大等待时间   请求间的间隔时间
    min_wait = 1000
    max_wait = 2000
